<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>操作元素属性</title>
</head>
<body>
    <box id="box"></box>
    <input type="text" id="username" placeholder="用户名" value="text">
    <input type="checkbox" checked id="checkbox">
    <script>
        box.innerHTML = "123"
        console.log(username.type)
        console.log(checkbox.checked)
        box.setAttribute("data-id", "123456")
        console.log(box.getAttribute("data-id"))
        console.log(box.dataset.id)
        console.log(box.dataset)
        console.log(box.dataset.id = "654321")
        box.removeAttribute("data-id")
        delete box.dataset.id
    </script>
</body>
</html>